using micromsg;
using MicroMsg.Common.Event;
using MicroMsg.Common.Utils;
using MicroMsg.Manager;
using MicroMsg.Protocol;
using System;
namespace MicroMsg.Scene
{
	public class NetScenePushChannelUnReg : NetSceneBaseEx<WinphoneUnRegRequest, WinphoneUnRegResponse, WinphoneUnRegRequest.Builder>
	{
		private const string TAG = "NetScenePushChannelUnReg";
		public bool doScene()
		{
			PushChannelSettings pushChannelSettings = GConfigMgr.smethod_0<PushChannelSettings>();
			if (pushChannelSettings.strPushChannelUri != null && pushChannelSettings.strPushChannelUri.get_Length() > 0)
			{
				Log.smethod_4("NetScenePushChannelUnReg", "unregister push channel start..... ");
				base.beginBuilder();
				this.mBuilder.BaseRequest = NetSceneBase.makeBaseRequest(0);
				this.mBuilder.Uri = pushChannelSettings.strPushChannelUri;
				this.mSessionPack.mConnectMode = 2;
				this.mSessionPack.mCmdUri = "/cgi-bin/micromsg-bin/winphoneunreg";
				base.endBuilder();
				return true;
			}
			Log.smethod_4("NetScenePushChannelUnReg", "cannot unregister push channel without invalid uri. ");
			return false;
		}
		protected override void onFailed(WinphoneUnRegRequest request, WinphoneUnRegResponse response)
		{
			Log.smethod_1("NetScenePushChannelUnReg", "unregister push channel failed. ");
			EventCenter.postEvent(EventConst.ON_NETSCENE_PUSHCHANNEL_UNREG_OVER, null, null);
		}
		protected override void onSuccess(WinphoneUnRegRequest request, WinphoneUnRegResponse response)
		{
			RetConst ret = (RetConst)response.BaseResponse.Ret;
			if (ret == RetConst.MM_OK)
			{
				Log.smethod_4("NetScenePushChannelUnReg", "unregister push channel success.  uri = " + request.Uri);
				PushNotifyMgr.cleanPushSetting();
				EventCenter.postEvent(EventConst.ON_NETSCENE_PUSHCHANNEL_UNREG_OVER, null, null);
				return;
			}
			Log.smethod_1("NetScenePushChannelUnReg", "unregister push channel failed,ret = " + ret);
			EventCenter.postEvent(EventConst.ON_NETSCENE_PUSHCHANNEL_UNREG_OVER, null, null);
		}
	}
}
